<div class="">
    <div class="admin_nrtop">
        <div class="couriercompanycz">
            <div class="nui-toolbar-item">
                <div class="nui-btn ">
                    <a class="nui-btn-text" href="/admini/express/index"><span>&lt;&lt;</span>返回</a>
                </div>
            </div>
            <div class="nui-toolbar-item">
                <div class="nui-btn ">
                    <a class="nui-btn-text" name='save' href="javascript:;">保存设置</a>
                </div>
                <div class="nui-btn ">
                    <a class="nui-btn-text" name='reset' href="javascript:;">重置</a>
                </div>
            </div>  
        </div>
    </div>
    <div class="addbox">
        <div class="addtop">
            <h1>
                <?php echo $this->express->name; ?>VIP优惠设置
            </h1>
        </div>
        <div class="addvip">
            <table>
                <tbody><tr>
                    <th class="vl">优惠项</th>
                    <th>高级会员</th>
                    <th>黄金会员</th>
                    <th>铂金会员</th>
                    <th>钻石会员</th>
                </tr>
                <tr>
                    <td class="vl">首重</td>
                    <td><input type="text" name="s1" id="s1" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[0] ? $this->vip[0]->Advanced : ''; ?>" > <i>折</i> </td>
                    <td><input type="text" name="s2" id="s2" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[0] ? $this->vip[0]->Gold : ''; ?>" >     <i>折</i> </td>
                    <td><input type="text" name="s3" id="s3" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[0] ? $this->vip[0]->Platinum : ''; ?>" > <i>折</i> </td>
                    <td><input type="text" name="s4" id="s4" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[0] ? $this->vip[0]->Jewel : ''; ?>" >    <i>折</i> </td>
                </tr>
                <tr>
                    <td class="vl">续重</td>
                    <td><input type="text" name="x1" id="x1" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[1] ? $this->vip[1]->Advanced : ''; ?>" > <i>折</i> </td>
                    <td><input type="text" name="x2" id="x2" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[1] ? $this->vip[1]->Gold : ''; ?>" >     <i>折</i> </td>
                    <td><input type="text" name="x3" id="x3" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[1] ? $this->vip[1]->Platinum : ''; ?>" > <i>折</i> </td>
                    <td><input type="text" name="x4" id="x4" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[1] ? $this->vip[1]->Jewel : ''; ?>" >    <i>折</i> </td>
                </tr>
                <tr>
                    <td class="vl">按公斤计费</td>
                    <td><input type="text" name="g1" id="g1" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[2] ? $this->vip[2]->Advanced : ''; ?>" > <i>折</i> </td>
                    <td><input type="text" name="g2" id="g2" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[2] ? $this->vip[2]->Gold : ''; ?>" >     <i>折</i> </td>
                    <td><input type="text" name="g3" id="g3" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[2] ? $this->vip[2]->Platinum : ''; ?>" > <i>折</i> </td>
                    <td><input type="text" name="g4" id="g4" class="txtBxF" datatype="float" value="<?php echo $this->vip && $this->vip[2] ? $this->vip[2]->Jewel : ''; ?>" >    <i>折</i> </td>
                </tr>
            </tbody></table>
        </div>
    </div>
    <div class="addbar">
        <ul>
            <li><a href="javascript:;" class="ccbotton" name='save'><span>保存设置</span></a></li>
            <li><a href="javascript:;" class="ccbotton2" name='reset'><span>重置</span></a></li>
        </ul>
    </div>
</div>
<script>
    $(function(){
        $('[name=reset]').click(function(){
            location.reload();
        })

        $('[name=save]').click(function(){
            var text = $('[type=text]');
            var run  = true;
            text.each(function(){
                var val = $.trim($(this).val());
                if(val == '' || val < 0 || val > 10 || isNaN(val)){
                    val = 10;
                    $(this).val('10');
                }
                if(val < 5){
                    run  = false;
                }
            })

            if(!run){
                if(!confirm('请确认折扣范围')){
                    return false;
                }
            }

            //首重
            var s1 = $.trim($('#s1').val());
            var s2 = $.trim($('#s2').val());
            var s3 = $.trim($('#s3').val());
            var s4 = $.trim($('#s4').val());
            //续重
            var x1 = $.trim($('#x1').val());
            var x2 = $.trim($('#x2').val());
            var x3 = $.trim($('#x3').val());
            var x4 = $.trim($('#x4').val());
            //按公斤计费
            var g1 = $.trim($('#g1').val());
            var g2 = $.trim($('#g2').val());
            var g3 = $.trim($('#g3').val());
            var g4 = $.trim($('#g4').val());

            $.ajax({
                url : '/admini/express/vipsave',
                type: 'get',
                dataType: 'json',
                data: {
                    'id' : '<?php echo $this->express->id; ?>',
                    's1' : s1,
                    's2' : s2,
                    's3' : s3,
                    's4' : s4,
                    'x1' : x1,
                    'x2' : x2,
                    'x3' : x3,
                    'x4' : x4,
                    'g1' : g1,
                    'g2' : g2,
                    'g3' : g3,
                    'g4' : g4,
                },
                success: function(_d, _s) {
                    console.log(_d);
                    alert(_d.m);
                    if(_d.s <= 10){
                        location.href = '/admini/express/vipview/id/<?php echo $this->express->id; ?>';
                    }
                }
            });
        })
    })
</script>